package com.gxg.newdemo1.mynewdamo1;

import android.app.Application;
import android.content.Context;

import com.gxg.newdemo1.mynewdamo1.channel.db.SQLHelper;

public class BaseApplication extends Application {
    private static  BaseApplication instance;
    private SQLHelper sqlHelper;
    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
    }

    public static BaseApplication getInstance(){
        return instance;
    }
    /**
     * 获取数据库Helper
     */
    public SQLHelper getSQLHelper() {
        if (sqlHelper == null)
            sqlHelper = new SQLHelper(instance);
        return sqlHelper;
    }

    @Override
    public void onTerminate() {
        // TODO Auto-generated method stub
        if (sqlHelper != null)
            sqlHelper.close();
        super.onTerminate();
        //整体摧毁的时候调用这个方法
    }


}
